package com.moxigua.iotbox.base;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.app.Fragment;
import android.widget.Toast;

import com.xiasuhuei321.loadingdialog.view.LoadingDialog;

/**
 * A simple {@link Fragment} subclass.
 */
public class BaseFragment extends Fragment {
    private Toast mToast;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mToast = Toast.makeText(getActivity(),"",Toast.LENGTH_SHORT);
    }

    protected void showShortToast(@StringRes int resId){
        mToast.setText(resId);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.show();
    }
    protected void showShortToast(String text){
        mToast.setText(text);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.show();
    }

    protected void showLongToast(@StringRes int resId){
        mToast.setText(resId);
        mToast.setDuration(Toast.LENGTH_LONG);
        mToast.show();
    }

    protected void showLongToast(String text){
        mToast.setText(text);
        mToast.setDuration(Toast.LENGTH_LONG);
        mToast.show();
    }

    protected void startActivity(Class<?> cls, Bundle... bundle){
        Intent intent = new Intent();
        intent.setClass(getActivity(), cls);
        if(bundle != null){
            intent.putExtras(bundle[0]);
        }
        startActivity(intent);
    }
}
